<?php
	$id = $_GET["id"];
	$loi = "";
	if(isset($id)){
	if(isset($_POST["ok"])){
		if($_POST["xe"] == null){
			echo $loi[] = "Chua nhap xe";
		}else{
			$x = $_POST["xe"];
		}
		if($_POST["gia"] == null){
			echo $loi[] = "Chua nhap gia";
		}else{
			$g = $_POST["gia"];
		}
		if($_FILES['img']['name'] != ""){
			$upload=new Upload($_FILES["img"]);
			if($upload->do_upload() == TRUE){
				$upload->do_upload();
				$img="upload/".$_FILES["img"]["name"];
			}
		}
		$duyet = $_POST["kiemduyet"];
		$hang = $_POST["hang"];
		$loai = $_POST["loai"];
		$tt = $_POST["tt"];
		if($x && $g && $img && $duyet && $hang && $loai && $tt && $id){
			$edit = new mxe();
			$edit->setxe($x);
			$edit->sethinhanh($img);
			$edit->setkiemduyet($duyet);
			$edit->sethang($hang);
			$edit->setloai($loai);
			$edit->settrangthai($tt);
			$edit->setgia($g);
			$edit->edit($id);
			header("location: index.php?module=xe&action=list");
			exit();
		}
	}
	}
	
	$show = new mxe();
	$row1 = $show->listxe1($id);
	require ("views/xe/vedit.php");
?>